# Alex Gazmararian
# agazmararian@gmail.com
# Coefficient mapping for table presentation

options(tinytable_theme_placement_latex_float = "H")
options(modelsummary_stars_note = FALSE)

gm <- modelsummary::gof_map
gm$omit <- TRUE
gm[gm$raw == "adj.r.squared", ]$clean <- "Adjusted $R^2$"
gm[gm$raw == "adj.r.squared", ]$omit <- FALSE
gm[gm$raw == "nobs", ]$clean <- "$N$"
gm[gm$raw == "nobs", ]$omit <- FALSE

# Specify variable mappings for table presentation
coefmap <- c(
    "(Intercept)" = "Intercept",
    # Project distance metrics for individual-level analyses
    # 1-year window versions
    "d_mfg_open_qQ1" = "Q1 proximity",
    "d_mfg_open_qQ2" = "Q2 proximity",
    "d_mfg_open_qQ3" = "Q3 proximity",
    "d_mfg_open_qQ4" = "Q4 proximity",
    "d_re_qQ1" = "Q1 proximity",
    "d_re_qQ2" = "Q2 proximity",
    "d_re_qQ3" = "Q3 proximity",
    "d_re_qQ4" = "Q4 proximity",
    # 2-year window versions
    "d_mfg_open_2y_qQ1" = "Q1 proximity",
    "d_mfg_open_2y_qQ2" = "Q2 proximity",
    "d_mfg_open_2y_qQ3" = "Q3 proximity",
    "d_mfg_open_2y_qQ4" = "Q4 proximity",
    "d_re_2y_qQ1" = "Q1 proximity",
    "d_re_2y_qQ2" = "Q2 proximity",
    "d_re_2y_qQ3" = "Q3 proximity",
    "d_re_2y_qQ4" = "Q4 proximity",

    # Individual-level covariates for survey analyses
    "age" = "Age",
    "female" = "Female",
    "black" = "Black",
    "asian" = "Asian",
    "otherrace" ="Other race",
    "hispanic" = "Hispanic/Latino",
    "college" = "College",
    "employ_bin" = "Employed",
    "income5Q2" = "Income Q2",
    "income5Q3" = "Income Q3",
    "income5Q4" = "Income Q4",
    "income5Q5" = "Income Q5",
    "pid3Republican" = "Republican",
    "pid3Neither" = "Neither party",
    "gw_idx" = "Global warming index",
    "popd_z" = "Population density", 

    # More macro controls
    "sectorEVs" = "Sector: EVs",
    "sectorSolar" = "Sector: Solar",
    "sectorWind" = "Sector: Wind",
    "capital_bin" = "Investment amount specified",
    "target_jobs_bin" = "Target jobs specified",
    "manufacturing_bin" = "Manufacturing investment",
    "statusOperating" = "Status: Operating",
    "statusPilot/Planned/Construction" = "Status: Pilot/Planned/Construction",

    "college_acs_z" = "County college share ($t-1$)",
    "poverty_acs_z" = "County poverty share ($t-1$)",
    "foreign_acs_z" = "County foreign-born share ($t-1$)",
    "housing_acs_z" = "Median county housing costs ($t-1$)",
    
    "bb100_bin" = "Faster broadband access ($t-1$)",
    "bb100>800"="Broadband: $>$800 ($t-1$)",
    "bb100600-800"="Broadband: 600-800 ($t-1$)",
    "bb100400-600"="Broadband: 400-600 ($t-1$)",

    "gdp_ln_z" = "County GDP (log) ($t-1$)",
    "force_ln_z"="Labor force (log) ($t-1$)",
    "urate_z" = "County unemployment rate ($t-1$)",
    "highway" = "Highway access",
    "income_pc_z"="County income pc ($t-1$)",

    # Investment location political characteristics
    "partyR" = "Republican speaker",
    "demshare_major_z" = "County 2020 Biden vote share",
    "rep_partyR" = "Republican Representative",
    "gov_partyR" = "Republican Governor",
    "swingstate" = "Swing state",
    "is_competitive_cong" = "Competitive congressional district",
    # State-level characteristics
    "eprice_z" = "State electricity price ($t-1$)",
    "eprice" = "State electricity price",
    "union_mem_z" = "State unionization rate ($t-1$)",
    "union_mem" = "State unionization rate",
    "govpartyR" = "Republican Governor",
    "govpartyR:pid3Republican" = "GOP Gov. $\\times$ Republican",
    "govpartyR:pid3Neither" = "GOP Gov. $\\times$ Neither party",
    "greenproj_bin" = "Visible green project",
    # Time controls
    "factor(year)2022" = "2022",
    "factor(year)2023" = "2023",
    "factor(year)2024" = "2024"
)
